
import NetUtils from '../utils/NetUtils'
import React, { useEffect, useState } from 'react';
import { ActivityIndicator, FlatList, Text, View } from 'react-native';

export default App = () => {
  const [isLoading, setLoading] = useState(true);
  const [data, setData] = useState([]);

  useEffect(() => {
    const params = {
      page: 1,
      tab: 'job',
      limit: 11
    }
    NetUtils.get('https://cnodejs.org/api/v1/topics', params, (result) => {
      setData(result.data)
      setLoading(false)
      // ToastAndroid.show(result.resultDesc, ToastAndroid.SHORT);
    });
  }, []);

  return (
    <View style={{ flex: 1, padding: 24 }}>
      {isLoading ? <ActivityIndicator /> : (
        <FlatList
          data={data}
          keyExtractor={({ id }, index) => id}
          renderItem={({ item }) => (
            <Text>{item.title}, {item.last_reply_at}</Text>
          )}
        />
      )}
    </View>
  );
};